from PySide6.QtCore import Signal, Slot, Signal, qDebug, QThread, Qt
from PySide6.QtGui import QAction
from PySide6.QtWidgets import QWidget, QMenuBar


class MenuWidgets(QWidget):
    closeApp = Signal(bool)
    exportDataDialog = Signal(bool)
    finished = Signal()

    def __init__(self, parent=None, parentWidget=None):
        super().__init__(parent)
        self.menuBar = QMenuBar(parentWidget)
        self.setupFileMenu()
        self.parentWidget = parentWidget

    def setupFileMenu(self):
        self.menuFile = self.menuBar.addMenu("文件")

        self.menuExportData = QAction("导出数据", self.menuBar)
        self.menuCheckUpgrade = QAction("检查版本", self.menuBar)
        self.menuExit = QAction("退出", self.menuBar)
        
        self.menuFile.addAction(self.menuExportData)
        self.menuFile.addSeparator()
        self.menuFile.addAction(self.menuCheckUpgrade)
        self.menuFile.addAction(self.menuExit)

        self.menuExit.triggered.connect(self.exit)
        self.menuExportData.triggered.connect(self.showExportDataDialog)

    def exit(self):
        """
        退出程序
        """
        self.closeApp.emit(True)

    def showExportDataDialog(self):
        """
        显示导出数据的dialog
        """
        self.exportDataDialog.emit(True)


